home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Programming / AmigaTalk / Intuition / Glyph.st < prev    next >
Text File  |  2000-05-02  |  3KB  |  110 lines

  1. "-------------------------------------------------------------------"
  2. " Glyph Class is just an abstract class that ties together all Amiga"
  3. " Graphics-related Classes & answers general questions about Glyphs."
  4. "-------------------------------------------------------------------"
  5.  
  6. Class Glyph :Object
  7. [
  8.    == aGlyph
  9.       ^ <primitive 7 self aGlyph>
  10. |
  11.    ~~ x
  12.       ^ (self == x) not
  13. |
  14.    = x
  15.       ^ (self == x)
  16. |
  17.    ~= x
  18.       ^ (self = x) not
  19. |
  20.    asString
  21.       ^ <primitive 152 (self class)> "Avoid Recursion!!"
  22.       "^ self class printString <<-- Infinite recursive method."
  23. |
  24.    asSymbol
  25.       ^ self asString asSymbol
  26. |
  27.    class
  28.       ^ <primitive 1 self>
  29. |
  30.    copy
  31.       ^ self shallowCopy
  32. |
  33.    deepCopy ! size newobj !
  34.       size <- <primitive 4 self>.
  35.  
  36.       (size < 0) 
  37.          ifTrue:  [^ self] "if special Object, just copy object"
  38.          ifFalse: [ newobj <- self class new.
  39.                     (1 to: size) 
  40.                        do: [:i | <primitive 112 newobj i (<primitive 111 self i> copy)> ].
  41.  
  42.                     ^ newobj ]
  43. |
  44.    do: aBlock ! item !
  45.      item <- self first.
  46.      ^ [item notNil] whileTrue:
  47.          [aBlock value: item.  item <- self next]
  48. |
  49.    error: aString
  50.      <primitive 122 aString self>
  51. |
  52.    first
  53.       ^ self
  54. |
  55.    isKindOf: aClass  ! objectClass !
  56.       objectClass <- self class.
  57.       [ objectClass notNil] 
  58.       whileTrue:
  59.          [ (objectClass == aClass) ifTrue: [^ true].
  60.            objectClass <- objectClass superClass
  61.          ].
  62.       ^ false
  63. |
  64.    isMemberOf: aClass
  65.       ^ aClass == self class
  66. |
  67.    isNil
  68.       ^ false
  69. |
  70.    next
  71.       ^ nil
  72. |
  73.    notNil
  74.       ^ true
  75. |
  76.    print
  77.       <primitive 121 (self printString)>
  78. |
  79.    printString
  80.       ^ self asString
  81. |
  82.    respondsTo: cmd
  83.       ^ self class respondsTo: cmd
  84. |
  85.    shallowCopy ! size newobj !
  86.       size <- <primitive 4 self>.
  87.       (size < 0)
  88.          ifTrue: 
  89.             [^ self]            "if special just copy object"
  90.          ifFalse: 
  91.             [ newobj <- self class new.
  92.               (1 to: size) 
  93.                do: 
  94.                  [:i | <primitive 112 newobj i <primitive 111 self i>>].
  95.                        ^ newobj 
  96.                  ]
  97. |
  98.    addressOf
  99.       super subclassResponsibility: 'addressOf'
  100.       "self error: 'This message should be implemented in a SubClass!'"
  101. |
  102.    glyphType
  103.       super subclassResponsibility: 'glyphType'
  104.       "self error: 'This message should be implemented in a SubClass!'"
  105. |
  106.    isDisplayed
  107.        super subclassResponsibility: 'isDisplayed'
  108.       "self error: 'This message should be implemented in a SubClass!'"
  109. ]
  110.